package collection;

import poly.Pet;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.LinkedBlockingDeque;

public class TravelMap {
    private Map<Integer, Pet> mp;//mp集合

    TravelMap(){//构造函数
        mp=new TreeMap<>();
        mp.put(1001,new Pet("abc","def",1));
        mp.put(1002,new Pet("ghi","jkl",2));
        mp.put(1003,new Pet("阿黄","张三",3));
        mp.put(1004,new Pet("黑色玫瑰","李四",4));
        Pet e=new Pet("白色蔷薇","william",5);
        mp.put(e.getId(),e);
        System.out.println(mp);
    }

        public void entryTravel(){
            LinkedBlockingDeque que;
            Set<Map.Entry<Integer,Pet>> set =mp.entrySet();//返回此地图中包含的键的Set视图
            for (Iterator<Map.Entry<Integer,Pet>> it =set.iterator(); it.hasNext();){
                Map.Entry<Integer,Pet> mae= it.next();

                System.out.println("key="+mae.getKey()+" value="+mae.getValue());

            }
        }


    }

//    public static void main(String[] args) {
//        TravelMap();
//    }


